package com.linln.modules.member.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.linln.common.data.PageSort;
import com.linln.modules.member.domain.MemberZan;
import com.linln.modules.member.repository.MemberZanRepository;
import com.linln.modules.member.service.MemberZanService;

/**
 * @author hct
 * @date 2019/09/12
 */
@Service
public class MemberZanServiceImpl implements MemberZanService {

    @Autowired
    private MemberZanRepository memberZanRepository;

    /**
     * 根据ID查询数据
     * @param id 主键ID
     */
    @Override
    @Transactional
    public MemberZan getById(Long id) {
        return memberZanRepository.findById(id).orElse(null);
    }
   @Override
   public MemberZan getByMemberIdAndTypeId(Long memberId,Integer type,Long storeId){
	   return memberZanRepository.getByMemberIdAndTypeId(memberId,type,storeId);
   }
   @Override
    public   Boolean delCollect(Long id){
	   boolean isOk=false;
	   try{
		   memberZanRepository.deleteById(id);
        isOk=true;
	   }catch(Exception e){
		   
	   }
       return isOk;
   }
    
    /**
     * 获取分页列表数据
     * @param example 查询实例
     * @return 返回分页数据
     */
    @Override
    public Page<MemberZan> getPageList(Example<MemberZan> example) {
        // 创建分页对象
        PageRequest page = PageSort.pageRequest();
        return memberZanRepository.findAll(example, page);
    }

    /**
     * 保存数据
     * @param MemberZan 实体对象
     */
    @Override
    public MemberZan save(MemberZan MemberZan) {
        return memberZanRepository.save(MemberZan);
    }

     
}